import { createRouter, createWebHistory } from "vue-router";
import Index from '../views/index.vue';

const routes = [
    {
        path: '/',
        component: Index,
        children: [{
            path: '/iot',
            children: [
                {
                    path: '/iot/gateway',
                    component: () => import('../views/iot/gateway.vue'),
                    meta: {
                        title: '网关管理'
                    }
                },
                {
                    path: '/iot/model',
                    component: () => import('../views/iot/model/index.vue'),
                    meta: {
                        title: '模型管理'
                    }
                },
                {
                    path: '/iot/device',
                    component: () => import('../views/iot/device.vue'),
                    meta: {
                        title: '设备管理'
                    }
                },
                {
                    path: '/iot/simulation',
                    component: () => import('../views/iot/simulation/index.vue'),
                    meta: {
                        title: '模拟工况'
                    }
                }
            ]
        }, {
            path: '/alarm',
            children: [
                {
                    path: '/alarm/define',
                    component: () => import('../views/iot/alarm/define/index.vue'),
                    meta: {
                        title: '报警定义'
                    }
                }, {
                    path: '/alarm/logs',
                    component: () => import('../views/iot/alarm/logs/index.vue'),
                    meta: {
                        title: '报警记录'
                    }
                }
            ]
        },
        {
            path: '/',
            children: [
                {
                    path: '/',
                    redirect: '/sys/dept'
                },
                {
                    path: '/sys/dept',
                    component: () => import('../views/sys/dept.vue'),
                    meta: {
                        title: '组织管理'
                    }
                }, {
                    path: '/sys/user',
                    component: () => import('../views/sys/user.vue'),
                    meta: {
                        title: '用户管理'
                    }
                }, {
                    path: '/sys/menu',
                    component: () => import('../views/sys/menu.vue'),
                    meta: {
                        title: '菜单管理'
                    }
                }, {
                    path: '/sys/role',
                    component: () => import('../views/sys/role/index.vue'),
                    meta: {
                        title: '角色管理'
                    }
                }, {
                    path: '/sys/config',
                    component: () => import('../views/sys/config.vue'),
                    meta: {
                        title: '配置管理'
                    }
                }, {
                    path: '/sys/dict',
                    component: () => import('../views/sys/dict/index.vue'),
                    meta: {
                        title: '字典管理'
                    }
                }
            ]
        }
        ]
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('../views/sys/login.vue'),
        meta: {
            public: true
        }
    },
    {
        path: '/404',
        name: '404',
        component: () => import('../views/sys/404.vue'),
        meta: {
            public: true
        }
    },
    {
        path: '/test',
        name: 'test',
        component: () => import('../views/test/test.jsx')
    }
]

const router = createRouter({
    routes,
    history: createWebHistory()
})

export default router;